import { Dayjs, dayjs } from '@/shared/internal/dayjs';

export interface DateRange {
  start: string;
  end: string;
}

export const getTodayRange = (): DateRange => {
  return {
    start: formatDate(dayjs().startOf('day')),
    end: formatDate(dayjs().endOf('day'))
  };
};

export const getSubtractDaysRange = (days: number): DateRange => {
  return {
    start: formatDate(dayjs().subtract(days, 'day').startOf('day')),
    end: formatDate(dayjs().endOf('day'))
  };
};

export const getCurrentMonthRange = (): DateRange => {
  return {
    start: formatDate(dayjs().startOf('month')),
    end: formatDate(dayjs().endOf('month'))
  };
};

export const getLast30DaysRange = (): DateRange => {
  return {
    start: formatDate(dayjs().subtract(30, 'day').startOf('day')),
    end: formatDate(dayjs().endOf('day'))
  };
};

export function formatDate(date: Dayjs) {
  return date.format('YYYY-MM-DD HH:mm:ss');
}
